home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / earcd / biz / dbase / db3_4src.lha / db3.4 / dialengine.a < prev    next >
Text File  |  1994-10-04  |  4KB  |  211 lines

  1. ; This source dials a number, it can do either DTMF or CCITT5. It has built
  2. ; in letter recognition. Ie ABC -> 1, DEF -> 2 which can be switched off.
  3. ; It is also variable speed. Feel free to use in your programmes.
  4. ;
  5. ; NB: This isnt the source of the programme dial, just the routine which
  6. ; dials numbers. Dial is merely a frontend to this:
  7. ;
  8. ; Original code by Andrew Leppard Internet: 9405571x@lux.levels.unisa.edu.au
  9. ; SAS C conversion and optimization by David Ekholm.
  10. ;
  11. ; Usage from C:
  12. ;    extern void __asm DialDTMF(register __a0 char *phonenumber,
  13. ;                                        register __d0, unsigned int speed);
  14. ;
  15. ;    extern void __asm DialCCITT5(register __a0 char *phonenumber,
  16. ;                                        register __d0, unsigned int speed);
  17. ;
  18.  
  19.         include "exec/funcdef.i"
  20.         include "exec/exec_lib.i"
  21.       include "exec/libraries.i"
  22.         include "hardware/custom.i"
  23.  
  24.         xdef _DialDTMF
  25.         xdef _DialCCITT5
  26.  
  27. callsys macro
  28.         LINKLIB _LVO\1,4
  29.         endm
  30.  
  31.         section  text,code
  32.  
  33. _DialDTMF                                            ;dial DTMF,
  34.         movem.l    d1/d4-d7/a3-a5,-(sp)                ;a0=number in ascii            
  35.         lea        DTMF,a1                            ;chr(0) to end        
  36.         bra        Start
  37.  
  38. _DialCCITT5                                            ;dial CCITT5,
  39.         movem.l    d1/d4-d7/a3-a5,-(sp)                ;a0=number in ascii
  40.         lea        CCITT5,a1                            ;chr(0) to end
  41.         
  42. Start move.b    d0,Speed
  43.         move.l    #SnWaveS,d0
  44.  
  45.         clr.l    d2
  46.         move.b    Speed,d2
  47.  
  48. NextTone
  49.         clr.l    d1
  50.         move.b    (a0)+,d1                            
  51.         cmp.b    #'*',d1
  52.         beq        Special
  53.         cmp.b    #'#',d1
  54.         beq        Special
  55.  
  56.         cmp.b    #'0',d1
  57.         blt        SkipNote
  58.         cmp.b    #'9',d1
  59.         bgt        NotDigit
  60.  
  61.         sub.b    #'0',d1
  62. DoneConv
  63.         lsl        #2,d1                                ;*4
  64.         move.w    0(a1,d1.w),d4                        ;Lookup table in words
  65.         move.w    2(a1,d1.w),d5                        ;get period of both tones
  66.         bsr        SoundTone
  67.         bra        Pause
  68. SkipNote
  69.         tst.b    (a0)
  70.         bne        NextTone
  71.  
  72.         movem.l    (sp)+,d1/d4-d7/a3-a5
  73.         rts
  74.  
  75. Special        move.w    #10,d1                                ;* & #
  76.         cmpi.b    #'#',d1                                ;(does anyone want the
  77.         bne        NoAdN                                ;a,b,c or d tones?)
  78.         addq.w    #1,d1
  79. NoAdN        bra        DoneConv
  80.  
  81. NotDigit                                            ;Handles a-y
  82.         tst.b    Letter                                ;-nl -ignore letters
  83.         bne        SkipNote
  84.         
  85.         cmp.b    #'Q',d1                                ;Q & Z = 1
  86.         beq        DoLQZ
  87.         cmp.b    #'Z',d1
  88.         beq        DoLQZ        
  89.         bgt        SmallCase
  90.         cmp.b    #'A',d1                                ;=> 1-9
  91.         blt        SkipNote
  92.         cmp.b    #'Q',d1
  93.         blt        NoDif
  94.         subq.b    #1,d1
  95. NoDif        sub.b    #59,d1
  96.         divu    #3,d1
  97.         bra        DoneConv
  98. DoLQZ        move.l    #1,d1
  99.         bra        DoneConv
  100.  
  101. SmallCase
  102.         cmp.b    #'z',d1
  103.         beq        DoLQZ                                ;Q and Z come on the 
  104.         bgt        SkipNote
  105.         cmp.b    #'q',d1                                ;Number 1 button 
  106.         beq        DoLQZ                                ;sometimes
  107.         cmp.b    #'a',d1
  108.         blt        SkipNote
  109.         cmp.b    #'q',d1
  110.         blt        NoDifS
  111.         subq.b    #1,d1
  112. NoDifS        sub.b    #91,d1
  113.         divu    #3,d1
  114.         bra        DoneConv
  115.  
  116. SoundTone
  117.         lea        $dff000,a5
  118.         lea        aud1(a5),a3                            ;Right channel only
  119.         lea        aud2(a5),a4                            ;N.B Don't be clever
  120.         move.w    #$000f,dmacon(a5)                    ;and use stereo it 
  121.         move.l    d0,(a3)                                ;doesn't work then.
  122.         move.l    d0,(a4)
  123.         move.w    #SnSize/2,ac_len(a3)
  124.         move.w    #SnSize/2,ac_len(a4)
  125.         move.w    #64,ac_vol(a3)
  126.         move.w    #64,ac_vol(a4)
  127.         move.w    d4,ac_per(a3)
  128.         move.w    d5,ac_per(a4)
  129.         move.w    #$00ff,adkcon(a5)
  130.         move.w    #$8206,dmacon(a5)
  131.  
  132. timedelay
  133.         bsr        GetTime
  134.         move.l    d7,d6
  135. Cont        bsr        GetTime
  136.         sub.l    d6,d7
  137.         cmp.l    d2,d7
  138.         bgt        StopNote        
  139.         bra        Cont
  140.  
  141. StopNote
  142.         move.w    #$0006,dmacon(a5)
  143.         rts
  144.  
  145. Pause        bsr        GetTime
  146.         move.l    d7,d6
  147. Cont2        bsr        GetTime
  148.         sub.l    d6,d7
  149.         cmpi.l    #2,d7
  150.         bgt        SkipNote
  151.         bra        Cont2
  152.  
  153. GetTime    clr.l    d7                                    ;Stuff the timer.device
  154.         move.b    $bfea01,d7                            ;we programme direct
  155.         lsl.l    #4,d7                                ;via PIA
  156.         lsl.l    #4,d7
  157.         move.b    $bfe901,d7
  158.         lsl.l    #4,d7
  159.         lsl.l    #4,d7
  160.         move.b    $bfe801,d7
  161.         rts
  162.  
  163.         section  __MERGED,data
  164.  
  165.         cnop 0,4
  166.  
  167. DTMF    dc.w    238,166                            ;0
  168.         dc.w    319,186                            ;1
  169.         dc.w    319,166                            ;2
  170.         dc.w    319,151                            ;3
  171.         dc.w    290,184                            ;4
  172.         dc.w    290,166                            ;5
  173.         dc.w    290,151                            ;6
  174.         dc.w    263,184                            ;7
  175.         dc.w    263,166                            ;8
  176.         dc.w    263,151                            ;9
  177.         dc.w    238,184                            ;* 
  178.         dc.w    238,151                            ;# 
  179.         
  180. CCITT5    dc.w    128,120                            ;0
  181.         dc.w    162,149                            ;1
  182.         dc.w    162,138                            ;2
  183.         dc.w    149,138                            ;3
  184.         dc.w    162,128                            ;4
  185.         dc.w    149,128                            ;5
  186.         dc.w    138,128                            ;6
  187.         dc.w    162,120                            ;7
  188.         dc.w    149,120                            ;8
  189.         dc.w    138,120                            ;9
  190.         dc.w    138,112                            ;* 
  191.         dc.w    128,112                            ;# 
  192.  
  193. Speed    dc.b    5                                ;speed of dial
  194. Letter    dc.b    0                                ;0 = use letter recognitiion
  195.  
  196.         section  chip,data,CHIP
  197.         cnop 0,4
  198. SnWaveS
  199.         dc.b    0,49
  200.         dc.b    90,117
  201.         dc.b    127,117
  202.         dc.b    90,49
  203.         dc.b    0,-49
  204.         dc.b    -90,-117
  205.         dc.b    -127,-117
  206.         dc.b    -90,-49
  207. SnWaveE    
  208. SnSize    EQU    SnWaveE-SnWaveS
  209.  
  210.         end    
  211.